﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace PloobsEngine.SceneControl
{
    public class AntiAliasingPostEffect : IPostEffect
    {
        private float weight = 2;

        /// <summary>
        /// Default 2
        /// Bigger value, bigger the effect
        /// </summary>
        public float Weight
        {
            get { return weight; }
            set { weight = value; }
        }

        private float pixelSizeMultiplier = 1;

        /// <summary>
        /// Default 1
        /// Change only if you Know what are you doing
        /// </summary>
        public float PixelSizeMultiplier
        {
            get { return pixelSizeMultiplier; }
            set { pixelSizeMultiplier = value; }
        }

        Effect effect = null;
        public void Draw(IRenderHelper rHelper,  Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {
                effect.Parameters["weight"].SetValue(weight);
                effect.Parameters["pixel_size"].SetValue(EngineStuff.HalfPixel * 2 * pixelSizeMultiplier);
                effect.Parameters["normal"].SetValue(rHelper[PrincipalConstants.normalRt]);
                
                rHelper.RenderTextureToFullScreenSpriteBatch(PrincipalConstants.CurrentImage, effect);                
        }

        public void init(EngineStuff engine)
        {
            effect = EngineStuff.InternalContentManager.GetAsset<Effect>("AntiAliasing");        
        }

    }
}
